package com.ecoolex.discount.sales.core.manager;

import com.ecoolex.discount.sales.core.dao.YwGiftOrderDeviceRecordDAO;
import com.ecoolex.discount.sales.entity.YwGiftOrderDeviceRecord;
import com.ecoolex.discount.sales.pojo.YwGiftOrderDeviceRecordDTO;

import java.time.Instant;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class YwGiftOrderDeviceRecordManager {
	
    @Autowired
    private YwGiftOrderDeviceRecordDAO dao;
    
    public void userDeviceInfoRecord(YwGiftOrderDeviceRecordDTO dto,String ip, String createUser) {
    	YwGiftOrderDeviceRecord record = new YwGiftOrderDeviceRecord();
    	record.setIpAddress(ip);
    	record.setReference(dto.getReference());
    	record.setBrowserName(dto.getBrowserName());
    	record.setBrowserVersion(dto.getBrowserVersion());
    	record.setDeleted(YwGiftOrderDeviceRecord.NOT_DELETED);
    	record.setCreateTime(Date.from(Instant.now()));
    	record.setCreateUser(createUser);
    	record.setUpdateTime(Date.from(Instant.now()));
    	record.setUpdateUser(createUser);
    	dao.insert(record);
	}
}